<?php

/**
 * This is the model class for table "tbl_contract_equip_schedule".
 *
 * The followings are the available columns in table 'tbl_contract_equip_schedule':
 * @property integer $id
 * @property string $contractid
 * @property integer $equipmentid
 * @property string $MonStart
 * @property string $MonEnd
 * @property string $TueStart
 * @property string $TueEnd
 * @property string $WedStart
 * @property string $WedEnd
 * @property string $ThuStart
 * @property string $ThuEnd
 * @property string $FriStart
 * @property string $FriEnd
 * @property string $SatStart
 * @property string $SatEnd
 * @property string $SunStart
 * @property string $SunEnd
 * @property string $lastupdate
 */
class ContractEquipSchedule extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return ContractEquipSchedule the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_contract_equip_schedule';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('contractid, equipmentid', 'required'),
			array('equipmentid', 'numerical', 'integerOnly'=>true),
			array('contractid', 'length', 'max'=>41),
			array('MonStart, MonEnd, TueStart, TueEnd, WedStart, WedEnd, ThuStart, ThuEnd, FriStart, FriEnd, SatStart, SatEnd, SunStart, SunEnd', 'length', 'max'=>8),
			array('lastupdate','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'update'),
			array('lastupdate','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'insert'),
			array('id, contractid, equipmentid, MonStart, MonEnd, TueStart, TueEnd, WedStart, WedEnd, ThuStart, ThuEnd, FriStart, FriEnd, SatStart, SatEnd, SunStart, SunEnd, lastupdate', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'contractid' => 'Contractid',
			'equipmentid' => 'Equipmentid',
			'MonStart' => 'Mon Start',
			'MonEnd' => 'Mon End',
			'TueStart' => 'Tue Start',
			'TueEnd' => 'Tue End',
			'WedStart' => 'Wed Start',
			'WedEnd' => 'Wed End',
			'ThuStart' => 'Thu Start',
			'ThuEnd' => 'Thu End',
			'FriStart' => 'Fri Start',
			'FriEnd' => 'Fri End',
			'SatStart' => 'Sat Start',
			'SatEnd' => 'Sat End',
			'SunStart' => 'Sun Start',
			'SunEnd' => 'Sun End',
			'lastupdate' => 'Lastupdate',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('contractid',$this->contractid,true);
		$criteria->compare('equipmentid',$this->equipmentid);
		$criteria->compare('MonStart',$this->MonStart,true);
		$criteria->compare('MonEnd',$this->MonEnd,true);
		$criteria->compare('TueStart',$this->TueStart,true);
		$criteria->compare('TueEnd',$this->TueEnd,true);
		$criteria->compare('WedStart',$this->WedStart,true);
		$criteria->compare('WedEnd',$this->WedEnd,true);
		$criteria->compare('ThuStart',$this->ThuStart,true);
		$criteria->compare('ThuEnd',$this->ThuEnd,true);
		$criteria->compare('FriStart',$this->FriStart,true);
		$criteria->compare('FriEnd',$this->FriEnd,true);
		$criteria->compare('SatStart',$this->SatStart,true);
		$criteria->compare('SatEnd',$this->SatEnd,true);
		$criteria->compare('SunStart',$this->SunStart,true);
		$criteria->compare('SunEnd',$this->SunEnd,true);
		$criteria->compare('lastupdate',$this->lastupdate,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}